
// 使用module，才能引入esm模块
const worker = new Worker('./worker1.js', { name: 'worker1', type: 'module' });

// 向worker发送消息
worker.postMessage('hello---222');

worker.onmessage = function (event) {
    console.log(event.data);
}